//package com.epoint.flinkdemo.sink;
//
//import org.apache.flink.api.common.functions.MapFunction;
//import org.apache.flink.api.common.serialization.SimpleStringSchema;
//import org.apache.flink.streaming.api.datastream.DataStream;
//import org.apache.flink.streaming.api.datastream.DataStreamSink;
//import org.apache.flink.streaming.api.datastream.DataStreamSource;
//import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
//import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
//import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer010;
//import org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer010;
//import scala.util.parsing.json.JSON;
//
//import java.util.Properties;
//
///**
// * @author liufl
// * @version [版本号, 21-4-9]
// */
//public class KafkaSinkTest
//{
//    public static void main(String[] args) throws Exception{
//        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
//
//        Properties properties = new Properties();
//        properties.setProperty("bootstrap.servers", "192.168.151.85:9092");
//        //        properties.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
//        //        properties.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
//
//        // 从testsource接收数据
//        DataStreamSource<String> kafkaStream = env.addSource(new FlinkKafkaConsumer010<String>("testsource", new SimpleStringSchema(), properties));
//
//        DataStream<String> kafkaMapStream = kafkaStream.map(new MapFunction<String, String>()
//        {
//            @Override
//            public String map(String value) throws Exception {
//                String[] str = value.split(",");
//                return "{\"name\":\""+str[0] + "\",\"value\":\""+str[1] + "\"}";
//            }
//        });
//
//        // kafkaStream.print();
//
//        // 把数据发送到kafka
//        DataStreamSink<String> testsink = kafkaMapStream.addSink(
//                new FlinkKafkaProducer010<String>("192.168.151.85:9092", "testsink", new SimpleStringSchema()));
//
//        env.execute();
//    }
//}
